<?php
require_once ROOT_PATH . '/core/Router.php';
require_once ROOT_PATH . '/core/Controller.php';
require_once ROOT_PATH . '/core/Model.php';
require_once ROOT_PATH . '/core/Database.php';

class App {
    protected $router;
    
    public function __construct() {
        $this->router = new Router();
        $this->registerRoutes();
    }
    
    protected function registerRoutes() {
        // 注册路由
        $this->router->add('/', 'HomeController', 'index');
        $this->router->add('/users', 'UserController', 'list');
        $this->router->add('/user/detail', 'UserController', 'detail');
    }
    
    public function run() {
        // 获取当前URL路径
        $url = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '/';
        
        // 分发请求
        $this->router->dispatch($url);
    }
}
?>